<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>项目搭建之SpringBoot基本操作归纳 | 袖清暮雨` Blog</title><meta name="author" content="袖清暮雨"><meta name="copyright" content="袖清暮雨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="1、springboot基本目录基本目录 讲解1234entity包：实体类mapper包：数据访问(sql语句)service包：业务层controller包：接口暴露地方【控制层】 2、springboot通用套路common层1、Result类——统一输出格式12345678910111213141516171819202122232425262728293031import lombok.">
<meta property="og:type" content="article">
<meta property="og:title" content="项目搭建之SpringBoot基本操作归纳">
<meta property="og:url" content="https://lemonworld.gitee.io/lemon-world/posts/7f721cb1.html">
<meta property="og:site_name" content="袖清暮雨&#96; Blog">
<meta property="og:description" content="1、springboot基本目录基本目录 讲解1234entity包：实体类mapper包：数据访问(sql语句)service包：业务层controller包：接口暴露地方【控制层】 2、springboot通用套路common层1、Result类——统一输出格式12345678910111213141516171819202122232425262728293031import lombok.">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png">
<meta property="article:published_time" content="2024-03-26T16:00:00.000Z">
<meta property="article:modified_time" content="2024-04-20T09:37:09.782Z">
<meta property="article:author" content="袖清暮雨">
<meta property="article:tag" content="Java">
<meta property="article:tag" content="传统开发">
<meta property="article:tag" content="SpringBoot">
<meta property="article:tag" content="项目搭建">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png"><link rel="shortcut icon" href="/lemon-world/./img/144.png"><link rel="canonical" href="https://lemonworld.gitee.io/lemon-world/posts/7f721cb1.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="manifest" href="/lemon-world/manifest.json"/><meta name="msapplication-TileColor" content="#3b70fc"/><link rel="apple-touch-icon" sizes="180x180" href="/lemon-world/img/siteicon/128.png"/><link rel="icon" type="image/png" sizes="32x32" href="/lemon-world/img/siteicon/32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/lemon-world/img/siteicon/16.png"/><link rel="mask-icon" href="/lemon-world/img/siteicon/128.png" color="#5bbad5"/><link rel="stylesheet" href="/lemon-world/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/lemon-world/',
  algolia: undefined,
  localSearch: {"path":"/lemon-world/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '项目搭建之SpringBoot基本操作归纳',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-04-20 17:37:09'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="/css/font.css"><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu@1.1.6/lib/clock.min.css" /><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 7.0.0"><link rel="alternate" href="/lemon-world/atom.xml" title="袖清暮雨` Blog" type="application/atom+xml">
</head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/lemon-world/./img/sanjiu.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/lemon-world/archives/"><div class="headline">文章</div><div class="length-num">39</div></a><a href="/lemon-world/tags/"><div class="headline">标签</div><div class="length-num">21</div></a><a href="/lemon-world/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/lemon-world/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa-solid fa-list"></i><span> 学习路线</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E4%B8%BB%E7%BA%BF/"><span> 学习主线</span></a></li><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E6%94%AF%E7%BA%BF/"><span> 学习支线</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/lemon-world/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/comments/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 更多</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/link/"><i class="fa-fw fas fa-link"></i><span> 相关链接</span></a></li><li><a class="site-page child" href="/lemon-world/picture/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png')"><nav id="nav"><span id="blog-info"><a href="/lemon-world/" title="袖清暮雨` Blog"><span class="site-name">袖清暮雨` Blog</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/lemon-world/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa-solid fa-list"></i><span> 学习路线</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E4%B8%BB%E7%BA%BF/"><span> 学习主线</span></a></li><li><a class="site-page child" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E6%94%AF%E7%BA%BF/"><span> 学习支线</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/lemon-world/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/lemon-world/comments/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 更多</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/lemon-world/link/"><i class="fa-fw fas fa-link"></i><span> 相关链接</span></a></li><li><a class="site-page child" href="/lemon-world/picture/"><i class="fa-fw fa fa-camera-retro"></i><span> 相册</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">项目搭建之SpringBoot基本操作归纳</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-03-26T16:00:00.000Z" title="发表于 2024-03-27 00:00:00">2024-03-27</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-20T09:37:09.782Z" title="更新于 2024-04-20 17:37:09">2024-04-20</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/lemon-world/categories/%E5%AD%A6%E4%B9%A0%E4%B8%BB%E7%BA%BF/">学习主线</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="leancloud_visitors" id="/lemon-world/posts/7f721cb1.html" data-flag-title="项目搭建之SpringBoot基本操作归纳"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span class="leancloud-visitors-count"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="1、springboot基本目录"><a href="#1、springboot基本目录" class="headerlink" title="1、springboot基本目录"></a>1、springboot基本目录</h1><h2 id="基本目录"><a href="#基本目录" class="headerlink" title="基本目录"></a>基本目录</h2><p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E5%8C%85%E5%9F%BA%E6%9C%AC%E7%9B%AE%E5%BD%95.png" alt="包的基本目录"></p>
<h3 id="讲解"><a href="#讲解" class="headerlink" title="讲解"></a>讲解</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">entity包：实体类</span><br><span class="line">mapper包：数据访问(sql语句)</span><br><span class="line">service包：业务层</span><br><span class="line">controller包：接口暴露地方【控制层】</span><br></pre></td></tr></table></figure>
<h1 id="2、springboot通用套路"><a href="#2、springboot通用套路" class="headerlink" title="2、springboot通用套路"></a>2、springboot通用套路</h1><h2 id="common层"><a href="#common层" class="headerlink" title="common层"></a>common层</h2><h3 id="1、Result类——统一输出格式"><a href="#1、Result类——统一输出格式" class="headerlink" title="1、Result类——统一输出格式"></a>1、Result类——统一输出格式</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> lombok.AllArgsConstructor;</span><br><span class="line"><span class="keyword">import</span> lombok.Builder;</span><br><span class="line"><span class="keyword">import</span> lombok.Data;</span><br><span class="line"><span class="keyword">import</span> lombok.NoArgsConstructor;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Data</span></span><br><span class="line"><span class="meta">@Builder</span></span><br><span class="line"><span class="meta">@AllArgsConstructor</span></span><br><span class="line"><span class="meta">@NoArgsConstructor</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Result</span>&lt;T&gt; &#123;</span><br><span class="line">    <span class="comment">//请求返回编码(成功与否)：0表示成功，1表示失败</span></span><br><span class="line">    <span class="keyword">private</span> Integer code;</span><br><span class="line">    <span class="comment">//提示信息</span></span><br><span class="line">    <span class="keyword">private</span> String msg;</span><br><span class="line">    <span class="comment">//响应数据：向前端返回后端数据(成功时才返回)</span></span><br><span class="line">    <span class="keyword">private</span> T data;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//快速返回操作成功响应数据（带响应数据）</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> &lt;E&gt; Result&lt;E&gt; <span class="title function_">success</span><span class="params">(E data)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">Result</span>&lt;&gt;(<span class="number">0</span>,<span class="string">&quot;请求成功&quot;</span>,data);</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">//快速返回操作成功响应数据</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> Result <span class="title function_">success</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">Result</span>(<span class="number">0</span>,<span class="string">&quot;请求成功&quot;</span>,<span class="literal">null</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> Result <span class="title function_">error</span><span class="params">(String msg)</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">Result</span>(<span class="number">1</span>,msg,<span class="literal">null</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="entity层-类"><a href="#entity层-类" class="headerlink" title="entity层(类)"></a>entity层(类)</h2><p><strong>常用注解</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">类：</span><br><span class="line">	@Data</span><br><span class="line">	@AllArgsConstructor</span><br><span class="line">	@NoArgsConstructor</span><br><span class="line">	@TableName	=&gt; 与数据库【表名】相关</span><br><span class="line">属性：</span><br><span class="line">	@TableId =&gt; 与数据库中【数据名】有关</span><br></pre></td></tr></table></figure>
<p><strong>@TableName和@TableId具体讲解</strong>：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">类名相关：</span><br><span class="line">@TableName(&quot;tb_user&quot;)			表名与类名不一致	✔</span><br><span class="line"></span><br><span class="line">属性相关：</span><br><span class="line">	表现形态：</span><br><span class="line">		@TableId()	✔</span><br><span class="line">		@TableField()	✔</span><br><span class="line">	具体讲解：</span><br><span class="line">			@TableId(type = IdType.AUTO)	自增列（标识主键）	✔</span><br><span class="line">			value=&quot;NAME&quot;					字段名不一致【若只是存在驼峰差异，开启驼峰后可或缺】	✔</span><br><span class="line">			exist=false						非表字段，默认为true</span><br><span class="line">			select=false					不加入查询，默认为true</span><br><span class="line">			strategy=&#x27;&#x27;					字段验证，默认非空	✔</span><br><span class="line">				insertStrategy=&quot;FieldStrategy.xxx&quot; 	在insert操作时的字段策略，是否进行空值判断，插入空值</span><br><span class="line">				updateStrategy=&quot;FieldStrategy.xxx&quot; 	在update操作时的字段策略，是否进行空值判断，插入空值</span><br><span class="line">				whereStrategy=&quot;FieldStrategy.xxx&quot; 	在where条件组装时，是否进行控制判断，将空值作为查询条件</span><br></pre></td></tr></table></figure>
<h2 id="mapper层-接口"><a href="#mapper层-接口" class="headerlink" title="mapper层(接口)"></a>mapper层(接口)</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">继承接口：</span><br><span class="line">	extends BaseMapper&lt;实体类&gt;</span><br></pre></td></tr></table></figure>
<h3 id="1-简单的sql操作"><a href="#1-简单的sql操作" class="headerlink" title="1.简单的sql操作"></a>1.简单的sql操作</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">注解(与sql相关)：</span><br><span class="line">	@insert</span><br><span class="line">	@select</span><br><span class="line">	...</span><br></pre></td></tr></table></figure>
<p><strong>注意点</strong></p>
<p>BaseMapper中包含了基本的操作，如insert(插入一条数据)，deleteById(根据ID删除)…</p>
<h3 id="2-复杂的sql操作"><a href="#2-复杂的sql操作" class="headerlink" title="2.复杂的sql操作"></a>2.复杂的sql操作</h3><p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/sql%E5%A4%8D%E6%9D%82.png" alt=""></p>
<p>在resources/mapping中创建XXXMapper.xml</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/sql%E5%A4%8D%E6%9D%82mapping.png" alt=""></p>
<h2 id="service层"><a href="#service层" class="headerlink" title="service层"></a>service层</h2><h3 id="service接口"><a href="#service接口" class="headerlink" title="service接口"></a>service接口</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">public interface ICartoonService extends IService&lt;Cartoon&gt; &#123;</span><br><span class="line">    //【追加功能】</span><br><span class="line">    IPage&lt;Cartoon&gt; getPage(int currentPage,int pageSize);</span><br><span class="line">	...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="service实体类"><a href="#service实体类" class="headerlink" title="service实体类"></a>service实体类</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">继承类和接口：</span><br><span class="line">	类：extends ServiceImpl&lt;Mapper接口, 实体类&gt;</span><br><span class="line">	接口：implements ICartoonService</span><br><span class="line">	</span><br><span class="line">类注解：</span><br><span class="line">	@Service</span><br><span class="line">	</span><br><span class="line">重写接口方法：【追加功能】</span><br><span class="line">	步骤一：引入mapper</span><br><span class="line">    	private CartoonMapper cartoonMapper;</span><br><span class="line"></span><br><span class="line">    	@Autowired</span><br><span class="line">    	public CartoonService(CartoonMapper cartoonMapper) &#123;</span><br><span class="line">        	this.cartoonMapper = cartoonMapper;</span><br><span class="line">    	&#125;</span><br><span class="line">    步骤二：重写</span><br><span class="line">    	@Override</span><br><span class="line">    	public IPage&lt;Cartoon&gt; getPage(int currentPage,int pageSize) &#123;</span><br><span class="line">        	IPage page = new Page(currentPage,pageSize);</span><br><span class="line">        	return cartoonMapper.selectPage(page,null);</span><br><span class="line">    	&#125;</span><br></pre></td></tr></table></figure>
<h2 id="controller层"><a href="#controller层" class="headerlink" title="controller层"></a>controller层</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">注解：</span><br><span class="line">	类注解：</span><br><span class="line">		@RestController</span><br><span class="line">		@RequestMapping(&quot;/admin/user&quot;)</span><br><span class="line">		@CrossOrigin：支持跨域，满足axios请求 【必加】</span><br><span class="line">	@Autowired =&gt; 构造器✔，属性...</span><br><span class="line">	方法注解：</span><br><span class="line">		@PostMapping：新增（Post）</span><br><span class="line">		@GetMapping：查询（GET）</span><br><span class="line">		@PutMapping：整体更新（Put）</span><br><span class="line">		@PatchMapping：局部更新（Patch）</span><br><span class="line">		@DeleteMapping：删除（Delete）</span><br><span class="line">	属性注解：</span><br><span class="line">		# URL路径部分，例如/blogs/1</span><br><span class="line">		@PathVariable(&quot;ps&quot;)</span><br><span class="line">		# 在参数部分(参数不存在时，默认值)，例如blogs?blogId=1</span><br><span class="line">			简单数据：</span><br><span class="line">				@RequestParam(value=&quot;id&quot;[,required=false[,defaultValue=&quot;0&quot;]])</span><br><span class="line">			复杂数据：</span><br><span class="line">				@RequestBody:前端为【json格式】</span><br><span class="line">				@ModelAttribute：前端为【字符串格式】</span><br><span class="line">				@MultipartFile：带有input=file的单表元素【上传照片，文件...】</span><br><span class="line"></span><br><span class="line">使用对象：</span><br><span class="line">	@Autowired</span><br><span class="line">	UserService userService;</span><br></pre></td></tr></table></figure>
<h2 id="启动层"><a href="#启动层" class="headerlink" title="启动层"></a>启动层</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">@SpringBootApplication(scanBasePackages = &#123;</span><br><span class="line">        &quot;com.ybg.common.entity&quot;,</span><br><span class="line">        &quot;com.ybg.common.image&quot;,</span><br><span class="line">        &quot;com.ybg.common.excel2&quot;,</span><br><span class="line">        &quot;com.ybg.common.xml&quot;,</span><br><span class="line">        ...</span><br><span class="line">&#125;)</span><br><span class="line">@MapperScan(basePackages = &quot;com.ybg.employee.business.mapper&quot;)</span><br><span class="line">public class EmployeeApplication &#123;</span><br><span class="line">    public static void main(String[] args) &#123;</span><br><span class="line">        SpringApplication.run(EmployeeApplication.class,args);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="3、SpringBoot基本操作"><a href="#3、SpringBoot基本操作" class="headerlink" title="3、SpringBoot基本操作"></a>3、SpringBoot基本操作</h1><h2 id="3-1插入操作（增）"><a href="#3-1插入操作（增）" class="headerlink" title="3.1插入操作（增）"></a>3.1插入操作（增）</h2><p><strong>UserMapper</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">@Insert(&quot;insert into `user` (username,password,name,phone,email,address,avatar) &quot; +</span><br><span class="line">        &quot;values (#&#123;username&#125;,#&#123;password&#125;,#&#123;name&#125;,#&#123;phone&#125;,#&#123;email&#125;,#&#123;address&#125;,#&#123;avatar&#125;)&quot;)</span><br><span class="line">void insertUser(User user);</span><br></pre></td></tr></table></figure>
<p><strong>UserService</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">private UserMapper userMapper;</span><br><span class="line"></span><br><span class="line">@Autowired</span><br><span class="line">public UserService(UserMapper userMapper) &#123;</span><br><span class="line">    this.userMapper = userMapper;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@Override</span><br><span class="line">public void insertUser(User user) &#123;</span><br><span class="line">    userMapper.insertUser(user);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService; //导入接口</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 新添用户</span><br><span class="line"> * @param user</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line">@PostMapping(&quot;/add&quot;)</span><br><span class="line">public Result add(@RequestBody User user)&#123;</span><br><span class="line">    try &#123;</span><br><span class="line">        userService.insertUser(user);</span><br><span class="line">    &#125;catch (Exception e)&#123;</span><br><span class="line">        if(e instanceof DuplicateKeyException)&#123;</span><br><span class="line">            return Result.error(&quot;插入数据库错误&quot;);</span><br><span class="line">        &#125;else&#123;</span><br><span class="line">            return Result.error(&quot;系统错误&quot;);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    return Result.success();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="3-2删除操作（删）"><a href="#3-2删除操作（删）" class="headerlink" title="3.2删除操作（删）"></a>3.2删除操作（删）</h2><h3 id="3-2-1单个删除"><a href="#3-2-1单个删除" class="headerlink" title="3.2.1单个删除"></a>3.2.1单个删除</h3><p><strong>UserMapper</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">@Delete(&quot;delete from `user` where id=#&#123;id&#125;&quot;)</span><br><span class="line">void deleteUser(Integer id);</span><br></pre></td></tr></table></figure>
<p><strong>UserService</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">private UserMapper userMapper;</span><br><span class="line"></span><br><span class="line">@Autowired</span><br><span class="line">public UserService(UserMapper userMapper) &#123;</span><br><span class="line">    this.userMapper = userMapper;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@Override</span><br><span class="line">public void deleteUser(Integer id) &#123;</span><br><span class="line">    userMapper.deleteUser(id);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 单个删除</span><br><span class="line"> * @param id</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line">@DeleteMapping(&quot;/delete/&#123;id&#125;&quot;)</span><br><span class="line">public Result delete(@PathVariable Integer id)&#123;</span><br><span class="line">    userService.deleteUser(id);</span><br><span class="line">    return Result.success();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="3-2-2批量删除"><a href="#3-2-2批量删除" class="headerlink" title="3.2.2批量删除"></a>3.2.2批量删除</h3><p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 批量删除</span><br><span class="line"> * @param ids</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line">@DeleteMapping(&quot;/delete/batch&quot;)</span><br><span class="line">public Result batchDelete(@RequestBody List&lt;Integer&gt; ids)&#123;</span><br><span class="line">    userService.removeBatchByIds(ids);</span><br><span class="line">    return Result.success();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/springboot%E6%89%B9%E9%87%8F%E5%88%A0%E9%99%A4%E6%93%8D%E4%BD%9C.png" alt=""></p>
<h2 id="3-3修改操作（改）"><a href="#3-3修改操作（改）" class="headerlink" title="3.3修改操作（改）"></a>3.3修改操作（改）</h2><p><strong>UserMapper</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">@Update(&quot;update `user` set username= #&#123;username&#125;,password=#&#123;password&#125;,name=#&#123;name&#125;,&quot; +</span><br><span class="line">        &quot;phone=#&#123;phone&#125;,email=#&#123;email&#125;,address=#&#123;address&#125;,avatar=#&#123;avatar&#125; where id = #&#123;id&#125;&quot;)</span><br><span class="line">void updateUser(User user);</span><br></pre></td></tr></table></figure>
<p><strong>UserService</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">private UserMapper userMapper;</span><br><span class="line"></span><br><span class="line">@Autowired</span><br><span class="line">public UserService(UserMapper userMapper) &#123;</span><br><span class="line">    this.userMapper = userMapper;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@Override</span><br><span class="line">public void updateUser(User user) &#123;</span><br><span class="line">    userMapper.updateUser(user);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 修改用户</span><br><span class="line"> * @param user</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line">@PutMapping(&quot;/update&quot;)</span><br><span class="line">public Result update(@RequestBody User user)&#123;</span><br><span class="line">    userService.updateUser(user);</span><br><span class="line">    return Result.success();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/springboot%E4%BF%AE%E6%94%B9%E6%93%8D%E4%BD%9C.png" alt=""></p>
<h2 id="3-4查询操作（查）"><a href="#3-4查询操作（查）" class="headerlink" title="3.4查询操作（查）"></a>3.4查询操作（查）</h2><h3 id="3-4-1：查询所有信息（倒序）"><a href="#3-4-1：查询所有信息（倒序）" class="headerlink" title="3.4.1：查询所有信息（倒序）"></a>3.4.1：查询所有信息（倒序）</h3><p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 查询所有信息</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line">@GetMapping(&quot;/selectAll&quot;)</span><br><span class="line">public Result selectAll()&#123;</span><br><span class="line">    List&lt;User&gt; userList = userService.list();</span><br><span class="line">    Collections.sort(userList, Comparator.comparing(User::getId).reversed());</span><br><span class="line">    return Result.success(userList);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="3-4-2：根据id进行查询"><a href="#3-4-2：根据id进行查询" class="headerlink" title="3.4.2：根据id进行查询"></a>3.4.2：根据id进行查询</h3><p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 根据id查询</span><br><span class="line"> * @param id</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line">@GetMapping(&quot;/selectById/&#123;id&#125;&quot;)</span><br><span class="line">public Result selectById(@PathVariable Integer id)&#123;</span><br><span class="line">    User user = userService.getById(id);</span><br><span class="line">    return Result.success(user);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="3-4-3：多条件模糊查询"><a href="#3-4-3：多条件模糊查询" class="headerlink" title="3.4.3：多条件模糊查询"></a>3.4.3：多条件模糊查询</h3><p><strong>UserMapper</strong></p>
<p>参数加上<strong>@Param</strong>注解</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">@Select(&quot;select * from `user` where username like concat(&#x27;%&#x27;,#&#123;username&#125;,&#x27;%&#x27;) and name like concat(&#x27;%&#x27;,#&#123;name&#125;,&#x27;%&#x27;) order by id desc&quot;)</span><br><span class="line">List&lt;User&gt; selectByMo(@Param(&quot;username&quot;) String username,@Param(&quot;name&quot;) String name);</span><br></pre></td></tr></table></figure>
<p><strong>UserService</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">private UserMapper userMapper;</span><br><span class="line"></span><br><span class="line">@Autowired</span><br><span class="line">public UserService(UserMapper userMapper) &#123;</span><br><span class="line">    this.userMapper = userMapper;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@Override</span><br><span class="line">public List&lt;User&gt; selectByMo(String username, String name) &#123;</span><br><span class="line">    return userMapper.selectByMo(username,name);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 多条件模糊查询</span><br><span class="line"> * 根据条件查询时，如果不确定查询结果有几个，那就统一返回一个List对象集合</span><br><span class="line"> */</span><br><span class="line">@GetMapping(&quot;/selectByMo&quot;)</span><br><span class="line">public Result selectByMo(@RequestParam String username,@RequestParam String name)&#123;</span><br><span class="line">    List&lt;User&gt; userList = userService.selectByMo(username,name);</span><br><span class="line">    return Result.success(userList);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/springboot%E5%A4%9A%E6%9D%A1%E4%BB%B6%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2.png" alt=""></p>
<h3 id="3-4-4：分页查询（查）"><a href="#3-4-4：分页查询（查）" class="headerlink" title="3.4.4：分页查询（查）"></a>3.4.4：分页查询（查）</h3><p><strong>MybatisPlus动态配置config</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">/*动态配置*/</span><br><span class="line">@Configuration</span><br><span class="line">public class MybatisPlusConfig &#123;</span><br><span class="line">    @Bean</span><br><span class="line">    public MybatisPlusInterceptor mybatisPlusInterceptor()&#123;</span><br><span class="line">        //1.定义MybatisPlus拦截器</span><br><span class="line">        final MybatisPlusInterceptor interceptor=new MybatisPlusInterceptor();</span><br><span class="line">        //添加具体的拦截器 =&gt; 分页查询</span><br><span class="line">        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));</span><br><span class="line">        return interceptor;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>UserService接口</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">IPage&lt;User&gt; getPage(int currentPage, int pageSize);</span><br></pre></td></tr></table></figure>
<p><strong>UserService实现类</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">// 追加功能</span><br><span class="line">private CartoonMapper cartoonMapper;</span><br><span class="line"></span><br><span class="line">@Autowired</span><br><span class="line">public CartoonService(CartoonMapper cartoonMapper) &#123;</span><br><span class="line">   	this.cartoonMapper = cartoonMapper;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">@Override</span><br><span class="line">public IPage&lt;User&gt; getPage(int currentPage, int pageSize) &#123;</span><br><span class="line">    IPage page = new Page(currentPage, pageSize);</span><br><span class="line">    //null:无约束条件(无条件查询)，默认全部查找 =&gt; queryWrapper</span><br><span class="line">    return userMapper.selectPage(page,null);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>UserController</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">@Autowired</span><br><span class="line">UserService userService;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * 分页查询</span><br><span class="line"> */</span><br><span class="line">@GetMapping(&quot;select/&#123;currentPage&#125;/&#123;pageSize&#125;&quot;)</span><br><span class="line">public IPage&lt;User&gt; getPage(@PathVariable(&quot;currentPage&quot;) int currentPage, @PathVariable(&quot;pageSize&quot;) int pageSize)&#123;</span><br><span class="line">    return userService.getPage(currentPage,pageSize);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="4、Http状态码"><a href="#4、Http状态码" class="headerlink" title="4、Http状态码"></a>4、Http状态码</h1><h3 id="200：成功"><a href="#200：成功" class="headerlink" title="200：成功"></a>200：成功</h3><p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/200.png" alt="200"></p>
<h3 id="400：接口参数错误"><a href="#400：接口参数错误" class="headerlink" title="400：接口参数错误"></a>400：接口参数错误</h3><p>后端需要传json格式，而此处传的是url参数，因此报400错误</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/400.png" alt="400"></p>
<h3 id="404：接口路径写错了或者参数写错了"><a href="#404：接口路径写错了或者参数写错了" class="headerlink" title="404：接口路径写错了或者参数写错了"></a>404：接口路径写错了或者参数写错了</h3><p>原本路径应为<a href="http://localhost:8080，而此处多添加了&quot;/hello">http://localhost:8080，而此处多添加了&quot;/hello</a>“</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/404.png" alt="404"></p>
<h3 id="405：接口请求类型不匹配"><a href="#405：接口请求类型不匹配" class="headerlink" title="405：接口请求类型不匹配"></a>405：接口请求类型不匹配</h3><p>应该为POST请求，而此处选择了GET请求，所以报405错误</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/405.png" alt="405"></p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/405%E9%A1%B5%E9%9D%A2.png" alt="405页面"></p>
<h3 id="500：后台错误"><a href="#500：后台错误" class="headerlink" title="500：后台错误"></a>500：后台错误</h3><h1 id="5、-Autowired报错Could-not-autowire-No-beans-of-‘XX‘-type-found"><a href="#5、-Autowired报错Could-not-autowire-No-beans-of-‘XX‘-type-found" class="headerlink" title="5、@Autowired报错Could not autowire. No beans of ‘XX‘ type found."></a>5、@Autowired报错Could not autowire. No beans of ‘XX‘ type found.</h1><p>@Autowired的自动检测级别太高，可以使用下边的方法，或者把Error级改为提示或者警告</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/Autowered%E6%8A%A5%E9%94%99%E5%A4%84%E7%90%86.png" alt=""></p>
<h1 id="6-工程打jar包的两种情形"><a href="#6-工程打jar包的两种情形" class="headerlink" title="6.工程打jar包的两种情形"></a>6.工程打jar包的两种情形</h1><h2 id="6-1资源jar包"><a href="#6-1资源jar包" class="headerlink" title="6.1资源jar包"></a>6.1资源jar包</h2><p>资源jar包：点击可以先选择“compile”，然后点击“<strong>instal</strong>”。</p>
<p>资源jar包主要存放于maven仓库中</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E8%B5%84%E6%BA%90jar%E5%8C%85.png" alt=""></p>
<h2 id="6-2可执行jar包"><a href="#6-2可执行jar包" class="headerlink" title="6.2可执行jar包"></a>6.2可执行jar包</h2><p>可执行jar包：点击可以先选择“compile”，然后点击“<strong>package</strong>”</p>
<p>可执行jar包可以在服务器或虚拟机中执行操作。</p>
<p><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E5%8F%AF%E6%89%A7%E8%A1%8Cjar%E5%8C%85.png" alt=""></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://lemonworld.gitee.io/lemon-world">袖清暮雨</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://lemonworld.gitee.io/lemon-world/posts/7f721cb1.html">https://lemonworld.gitee.io/lemon-world/posts/7f721cb1.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://lemonworld.gitee.io/lemon-world" target="_blank">袖清暮雨` Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/lemon-world/tags/Java/">Java</a><a class="post-meta__tags" href="/lemon-world/tags/%E4%BC%A0%E7%BB%9F%E5%BC%80%E5%8F%91/">传统开发</a><a class="post-meta__tags" href="/lemon-world/tags/SpringBoot/">SpringBoot</a><a class="post-meta__tags" href="/lemon-world/tags/%E9%A1%B9%E7%9B%AE%E6%90%AD%E5%BB%BA/">项目搭建</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/lemon-world/posts/452204e8.html" title="项目搭建之SpringBoot配置归纳"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png" onerror="onerror=null;src='/lemon-world/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">项目搭建之SpringBoot配置归纳</div></div></a></div><div class="next-post pull-right"><a href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E8%BF%BD%E6%9C%88.png" onerror="onerror=null;src='/lemon-world/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/lemon-world/posts/452204e8.html" title="项目搭建之SpringBoot配置归纳"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-03-18</div><div class="title">项目搭建之SpringBoot配置归纳</div></div></a></div><div><a href="/lemon-world/posts/ca437b77.html" title="项目搭建之Vue工程之初步搭建"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AC%BC%E7%81%AD.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-02-24</div><div class="title">项目搭建之Vue工程之初步搭建</div></div></a></div><div><a href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E8%BF%BD%E6%9C%88.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-11</div><div class="title">项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战</div></div></a></div><div><a href="/lemon-world/posts/cca50181.html" title="项目搭建之Vue工程之路由"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E5%A4%95%E9%98%B3%E4%B8%8B%E7%9A%84%E7%BA%A2%E8%B7%AF%E7%81%AF.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-12</div><div class="title">项目搭建之Vue工程之路由</div></div></a></div><div><a href="/lemon-world/posts/dc99e4b2.html" title="项目搭建之文件上传下载"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%97%B4%E8%B0%8D%E8%BF%87%E5%AE%B6%E5%AE%B6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-20</div><div class="title">项目搭建之文件上传下载</div></div></a></div><div><a href="/lemon-world/posts/54849ec2.html" title="大数据之Hadoop（HDFS Java客户端操作）"><img class="cover" src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E7%8E%9B%E5%A5%87%E7%8E%9B.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-01-14</div><div class="title">大数据之Hadoop（HDFS Java客户端操作）</div></div></a></div></div></div><hr class="custom-hr"/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/lemon-world/./img/sanjiu.jpg" onerror="this.onerror=null;this.src='/lemon-world/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">袖清暮雨</div><div class="author-info__description">一个技术宅的博客</div></div><div class="card-info-data site-data is-center"><a href="/lemon-world/archives/"><div class="headline">文章</div><div class="length-num">39</div></a><a href="/lemon-world/tags/"><div class="headline">标签</div><div class="length-num">21</div></a><a href="/lemon-world/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/Lemon-World"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Lemon-World" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">欢迎来到袖清暮雨`Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1%E3%80%81springboot%E5%9F%BA%E6%9C%AC%E7%9B%AE%E5%BD%95"><span class="toc-number">1.</span> <span class="toc-text">1、springboot基本目录</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E7%9B%AE%E5%BD%95"><span class="toc-number">1.1.</span> <span class="toc-text">基本目录</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B2%E8%A7%A3"><span class="toc-number">1.1.1.</span> <span class="toc-text">讲解</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2%E3%80%81springboot%E9%80%9A%E7%94%A8%E5%A5%97%E8%B7%AF"><span class="toc-number">2.</span> <span class="toc-text">2、springboot通用套路</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#common%E5%B1%82"><span class="toc-number">2.1.</span> <span class="toc-text">common层</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1%E3%80%81Result%E7%B1%BB%E2%80%94%E2%80%94%E7%BB%9F%E4%B8%80%E8%BE%93%E5%87%BA%E6%A0%BC%E5%BC%8F"><span class="toc-number">2.1.1.</span> <span class="toc-text">1、Result类——统一输出格式</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#entity%E5%B1%82-%E7%B1%BB"><span class="toc-number">2.2.</span> <span class="toc-text">entity层(类)</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#mapper%E5%B1%82-%E6%8E%A5%E5%8F%A3"><span class="toc-number">2.3.</span> <span class="toc-text">mapper层(接口)</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E7%AE%80%E5%8D%95%E7%9A%84sql%E6%93%8D%E4%BD%9C"><span class="toc-number">2.3.1.</span> <span class="toc-text">1.简单的sql操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%A4%8D%E6%9D%82%E7%9A%84sql%E6%93%8D%E4%BD%9C"><span class="toc-number">2.3.2.</span> <span class="toc-text">2.复杂的sql操作</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#service%E5%B1%82"><span class="toc-number">2.4.</span> <span class="toc-text">service层</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#service%E6%8E%A5%E5%8F%A3"><span class="toc-number">2.4.1.</span> <span class="toc-text">service接口</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#service%E5%AE%9E%E4%BD%93%E7%B1%BB"><span class="toc-number">2.4.2.</span> <span class="toc-text">service实体类</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#controller%E5%B1%82"><span class="toc-number">2.5.</span> <span class="toc-text">controller层</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8%E5%B1%82"><span class="toc-number">2.6.</span> <span class="toc-text">启动层</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3%E3%80%81SpringBoot%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C"><span class="toc-number">3.</span> <span class="toc-text">3、SpringBoot基本操作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1%E6%8F%92%E5%85%A5%E6%93%8D%E4%BD%9C%EF%BC%88%E5%A2%9E%EF%BC%89"><span class="toc-number">3.1.</span> <span class="toc-text">3.1插入操作（增）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-2%E5%88%A0%E9%99%A4%E6%93%8D%E4%BD%9C%EF%BC%88%E5%88%A0%EF%BC%89"><span class="toc-number">3.2.</span> <span class="toc-text">3.2删除操作（删）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-1%E5%8D%95%E4%B8%AA%E5%88%A0%E9%99%A4"><span class="toc-number">3.2.1.</span> <span class="toc-text">3.2.1单个删除</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-2%E6%89%B9%E9%87%8F%E5%88%A0%E9%99%A4"><span class="toc-number">3.2.2.</span> <span class="toc-text">3.2.2批量删除</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-3%E4%BF%AE%E6%94%B9%E6%93%8D%E4%BD%9C%EF%BC%88%E6%94%B9%EF%BC%89"><span class="toc-number">3.3.</span> <span class="toc-text">3.3修改操作（改）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-4%E6%9F%A5%E8%AF%A2%E6%93%8D%E4%BD%9C%EF%BC%88%E6%9F%A5%EF%BC%89"><span class="toc-number">3.4.</span> <span class="toc-text">3.4查询操作（查）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-1%EF%BC%9A%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E4%BF%A1%E6%81%AF%EF%BC%88%E5%80%92%E5%BA%8F%EF%BC%89"><span class="toc-number">3.4.1.</span> <span class="toc-text">3.4.1：查询所有信息（倒序）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-2%EF%BC%9A%E6%A0%B9%E6%8D%AEid%E8%BF%9B%E8%A1%8C%E6%9F%A5%E8%AF%A2"><span class="toc-number">3.4.2.</span> <span class="toc-text">3.4.2：根据id进行查询</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-3%EF%BC%9A%E5%A4%9A%E6%9D%A1%E4%BB%B6%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2"><span class="toc-number">3.4.3.</span> <span class="toc-text">3.4.3：多条件模糊查询</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-4%EF%BC%9A%E5%88%86%E9%A1%B5%E6%9F%A5%E8%AF%A2%EF%BC%88%E6%9F%A5%EF%BC%89"><span class="toc-number">3.4.4.</span> <span class="toc-text">3.4.4：分页查询（查）</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4%E3%80%81Http%E7%8A%B6%E6%80%81%E7%A0%81"><span class="toc-number">4.</span> <span class="toc-text">4、Http状态码</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#200%EF%BC%9A%E6%88%90%E5%8A%9F"><span class="toc-number">4.0.1.</span> <span class="toc-text">200：成功</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#400%EF%BC%9A%E6%8E%A5%E5%8F%A3%E5%8F%82%E6%95%B0%E9%94%99%E8%AF%AF"><span class="toc-number">4.0.2.</span> <span class="toc-text">400：接口参数错误</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#404%EF%BC%9A%E6%8E%A5%E5%8F%A3%E8%B7%AF%E5%BE%84%E5%86%99%E9%94%99%E4%BA%86%E6%88%96%E8%80%85%E5%8F%82%E6%95%B0%E5%86%99%E9%94%99%E4%BA%86"><span class="toc-number">4.0.3.</span> <span class="toc-text">404：接口路径写错了或者参数写错了</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#405%EF%BC%9A%E6%8E%A5%E5%8F%A3%E8%AF%B7%E6%B1%82%E7%B1%BB%E5%9E%8B%E4%B8%8D%E5%8C%B9%E9%85%8D"><span class="toc-number">4.0.4.</span> <span class="toc-text">405：接口请求类型不匹配</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#500%EF%BC%9A%E5%90%8E%E5%8F%B0%E9%94%99%E8%AF%AF"><span class="toc-number">4.0.5.</span> <span class="toc-text">500：后台错误</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5%E3%80%81-Autowired%E6%8A%A5%E9%94%99Could-not-autowire-No-beans-of-%E2%80%98XX%E2%80%98-type-found"><span class="toc-number">5.</span> <span class="toc-text">5、@Autowired报错Could not autowire. No beans of ‘XX‘ type found.</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#6-%E5%B7%A5%E7%A8%8B%E6%89%93jar%E5%8C%85%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%83%85%E5%BD%A2"><span class="toc-number">6.</span> <span class="toc-text">6.工程打jar包的两种情形</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#6-1%E8%B5%84%E6%BA%90jar%E5%8C%85"><span class="toc-number">6.1.</span> <span class="toc-text">6.1资源jar包</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-2%E5%8F%AF%E6%89%A7%E8%A1%8Cjar%E5%8C%85"><span class="toc-number">6.2.</span> <span class="toc-text">6.2可执行jar包</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/dc99e4b2.html" title="项目搭建之文件上传下载"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%97%B4%E8%B0%8D%E8%BF%87%E5%AE%B6%E5%AE%B6.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之文件上传下载"/></a><div class="content"><a class="title" href="/lemon-world/posts/dc99e4b2.html" title="项目搭建之文件上传下载">项目搭建之文件上传下载</a><time datetime="2024-04-19T16:00:00.000Z" title="发表于 2024-04-20 00:00:00">2024-04-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/cca50181.html" title="项目搭建之Vue工程之路由"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E5%A4%95%E9%98%B3%E4%B8%8B%E7%9A%84%E7%BA%A2%E8%B7%AF%E7%81%AF.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之Vue工程之路由"/></a><div class="content"><a class="title" href="/lemon-world/posts/cca50181.html" title="项目搭建之Vue工程之路由">项目搭建之Vue工程之路由</a><time datetime="2024-04-11T16:00:00.000Z" title="发表于 2024-04-12 00:00:00">2024-04-12</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E8%BF%BD%E6%9C%88.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战"/></a><div class="content"><a class="title" href="/lemon-world/posts/1e302926.html" title="项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战">项目搭建之前后端交互（跨域,页面跳转,Pinia）+实战</a><time datetime="2024-04-10T16:00:00.000Z" title="发表于 2024-04-11 00:00:00">2024-04-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/7f721cb1.html" title="项目搭建之SpringBoot基本操作归纳"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之SpringBoot基本操作归纳"/></a><div class="content"><a class="title" href="/lemon-world/posts/7f721cb1.html" title="项目搭建之SpringBoot基本操作归纳">项目搭建之SpringBoot基本操作归纳</a><time datetime="2024-03-26T16:00:00.000Z" title="发表于 2024-03-27 00:00:00">2024-03-27</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/lemon-world/posts/452204e8.html" title="项目搭建之SpringBoot配置归纳"><img src= "" data-lazy-src="https://gitee.com/LemonWorld/picture/raw/master/img/%E9%AD%94%E6%B3%95%E5%B0%91%E5%A5%B3%E5%B0%8F%E5%9C%86.png" onerror="this.onerror=null;this.src='/lemon-world/img/404.jpg'" alt="项目搭建之SpringBoot配置归纳"/></a><div class="content"><a class="title" href="/lemon-world/posts/452204e8.html" title="项目搭建之SpringBoot配置归纳">项目搭建之SpringBoot配置归纳</a><time datetime="2024-03-17T16:00:00.000Z" title="发表于 2024-03-18 00:00:00">2024-03-18</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gitee.com/LemonWorld/picture/raw/master/img/%E6%A1%A5%E4%B8%8B%E5%A4%95%E9%98%B3.png')"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2024 By 袖清暮雨</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">welcome to <a href="https://lemonworld.gitee.io/lemon-world/">袖清暮雨</a> Blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/lemon-world/js/utils.js"></script><script src="/lemon-world/js/main.js"></script><script src="/lemon-world/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><div class="js-pjax"><script>(() => {
  const initValine = () => {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'lmEQpOsJf8mT3BIGHZZ7EDq4-gzGzoHsz',
      appKey: '7APMLg7dJeJb0sE6hHymEyaY',
      avatar: 'monsterid',
      serverURLs: '7frkCVvvwQAZBPCcjmeKotvz',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: true
    }, null))
  }

  const loadValine = async () => {
    if (typeof Valine === 'function') initValine()
    else {
      await getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js')
      initValine()
    }
  }

  if ('Valine' === 'Valine' || !false) {
    if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
    else setTimeout(loadValine, 0)
  } else {
    window.loadOtherComment = loadValine
  }
})()</script></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><div class="app-refresh" id="app-refresh" style="position: fixed;top: -2.2rem;left: 0;right: 0;z-index: 99999;padding: 0 1rem;font-size: 15px;height: 2.2rem;transition: all 0.3s ease;"><div class="app-refresh-wrap" style=" display: flex;color: #fff;height: 100%;align-items: center;justify-content: center;"><label>✨ 有新文章啦！✨  👉</label><a href="javascript:void(0)" onclick="location.reload()"><span style="color: #fff;text-decoration: underline;cursor: pointer;">点击使用</span></a></div></div><script>if ('serviceWorker' in navigator) {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.addEventListener('controllerchange', function() {
showNotification()
})
}
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js')
})
}
function showNotification() {
if (GLOBAL_CONFIG.Snackbar) {
var snackbarBg =
document.documentElement.getAttribute('data-theme') === 'light' ?
GLOBAL_CONFIG.Snackbar.bgLight :
GLOBAL_CONFIG.Snackbar.bgDark
var snackbarPos = GLOBAL_CONFIG.Snackbar.position
Snackbar.show({
text: '✨ 有新文章啦！✨  👉',
backgroundColor: snackbarBg,
duration: 500000,
pos: snackbarPos,
actionText: '点击使用',
actionTextColor: '#fff',
onActionClick: function(e) {
location.reload()
},
})
} else {
var showBg =
document.documentElement.getAttribute('data-theme') === 'light' ?
'#3b70fc' :
'#1f1f1f'
var cssText = `top: 0; background: ${showBg};`
document.getElementById('app-refresh').style.cssText = cssText
}
}</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/lemon-world/js/search/local-search.js"></script></div></div><!-- hexo injector body_end start --><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src= "" data-lazy-src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu@1.1.6/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    if(parent_div_git) {
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var qweather_key = '8fb12d98d85c4c88831aa57a850d7b9f';
  var gaud_map_key = '70fbf493bf0d0ba744a308b047ea559e';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '112.6534116,27.96920845';
  var clock_default_rectangle_enable = 'true';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu@1.1.6/lib/clock.min.js"></script><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1.5s');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '30');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('flink-list-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__flipInY');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('flink-list-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__animated');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('article-sort-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__slideInRight');
    arr[i].setAttribute('data-wow-duration', '1.5s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('site-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__flipInY');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('site-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__animated');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/wow.min.js"></script><script defer src="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/wow_init.js"></script><!-- hexo injector body_end end --><script src="/lemon-world/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"tagMode":false,"debug":false,"model":{"jsonPath":"/lemon-world/live2dw/assets/koharu.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/"});</script></body></html>